<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>设备信息</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#inputForm").validate({
				rules : {
						 schoolId: {
							required : true
						 },
						 classroomId: {
								required : true
							 }
					},
				messages : {
				   		 schoolId: {
								required : "请选择"
							 },
						 classroomId: {
									required : "请选择"
							 }
					},
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			$("#schoolId").change(function(){
		        var schoolId=$("#schoolId").val();
		     $.ajax({
		         type: "POST",
		         url: "${ctx}/ajax/get/classroom.do",
		         data: {"schoolId"	:	schoolId},
		         dataType: 'json',
		         success: function(data) {
		               $("#classroomId").empty();
		               $("#classroomId").append("<option selected=\"selected\" value=\"\">请选择</option>" );
		               $.each(data, function(index,item){
		             		$("#classroomId").append('<option value='+item.id+'>'+item.name+'</option>');
		              }); 
		               $("#s2id_classroomId").find("span[class='select2-chosen']").html("请选择");
		             }
		  		});
		     });
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/dd/ddEquipment/">设备列表</a></li>
		<li class="active"><a href="${ctx}/dd/ddEquipment/form?id=${ddEquipment.id}">设备<shiro:hasPermission name="dd:ddEquipment:edit">${not empty ddEquipment.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="dd:ddEquipment:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="ddEquipment" action="${ctx}/dd/ddEquipment/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>	
		<c:if test="${not empty ddEquipment.id}">
		<div class="control-group">		 
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>设备编号：</label>
			<div class="controls">
				<form:input path="id" htmlEscape="false" maxlength="32" class="input-xlarge " readonly="true"/>
			</div>
		</div>	
		</c:if>
		<div class="control-group">		 
			<label class="control-label">所属学校：</label>
			<div class="controls">
				<%-- <form:input path="schoolId" htmlEscape="false" maxlength="32" class="input-xlarge "/> --%>
				 <form:select path="schoolId" class="input-mini form-control required ">
				 		        <form:option value="">请选择</form:option>
								<form:options items="${fns:getSchoolNameList()}" itemLabel="name"
									itemValue="id" htmlEscape="false" />
							</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">所属教室：</label>
			<div class="controls">
				 <form:select path="classroomId" class="input-mini form-control required ">		
									<form:option value="" selected="selected">请选择</form:option> 
							</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">
			<b style="color: red; font-size: large">*</b>设备名称：</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="200" class="input-xlarge " required="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">参数：</label>
			<div class="controls">
				<form:input path="parameter" htmlEscape="false" maxlength="5000" class="input-xlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="dd:ddEquipment:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>